<template>
	<view class="page container">
		<!-- 		<z-paging :refresher-enabled="false" :auto-full-height="false" :default-page-size="15" ref="pagingRef"
			v-model="dataList" @query="queryList" :paging-style="{ 'background-color': 'transparent' }"> -->

		<view class="h-28"></view>
		<view class="list ">
			<!--  -->
			<view class="item bgc-fff pad-28 flex-between-center" v-for="(item, index) in dataList" :key="index" @click="back(item)">
				<view class="texts">
					<view class="flex-between-center">
						<view class="flex-center-center">
							<u-text :lines="1" size="30rpx" color="#262624" :text="item.realname || ''"></u-text>
						<text style="margin-left: 20rpx;">{{item.phone}}</text>	
						<text class="default" v-if="item.is_default==1">默认</text>
						</view>
					</view>
					<view class="mt-12   c-D61F1F">
						<u-text :lines="2" size="26rpx" color="#666262" :text="item.province+item.city+item.region+item.addr || ''"></u-text>
					</view>
				</view>
				
				<view class="">
					<view @click.stop="edit(item)" :url="'/pages/addAddress/index?data='+JSON.stringify(item)" class="mb-15" >
						<u-icon name="edit-pen" color="#999" size="24"></u-icon>
					</view>
				
				</view>
			
				
				<!-- <view class="detail-btn w-124 h-60 br-12 flex-center-center">详情</view> -->
			</view>
		</view>
		<emptydata v-if="dataList.length==0"></emptydata>
		<navigator url="/pages/addAddress/index" hover-class="none" class="add" >
			添加新地址
		</navigator>
		<!-- <view v-else>
				<LandMap type="garden" ref="landMap" :data="dataList" @markerClick="handleMarkerClick" />
			</view> -->
		<!-- </z-paging> -->
	</view>
</template>

<script>
	import ScoreScreen from "@/components/ScoreScreen/index.vue";
	import LandMap from "@/components/LandMap.vue";
	import {
		addrList,
		delAddr
	} from "@/services/home.js";
	export default {
		components: {
			ScoreScreen,
			LandMap,
		},
		data() {
			return {
				overlay_show: false,
				viewType: "list",
				dataList: [],
				params: {
					title: "",
					lat: "",
					lng: "",
				},
				selectedValues: {},
			};
		},
		onLoad() {
			//获取当前经纬度
			console.log(this.n)

			// this.$refs.pagingRef?.reload();
			

		},
		onShow() {
			this.queryList()
		},

		methods: {
			onScreen(e) {
				const {
					area,
					distance,
					views
				} = e;
				const [city, district, town, village] = area;
				this.selectedValues = this.$options.data.selectedValues; //先还原
				const requestObj = {
					city: this.filterAll(city),
					district: this.filterAll(district),
					town: this.filterAll(town),
					village: this.filterAll(village),
					order_sort: {
						distance,
						see_num: views
					},
				};
				this.selectedValues = requestObj;
				this.$refs.pagingRef?.reload();
			},
			overlayShow(e) {
				this.overlay_show = e;
			},
			clickOverlay() {
				this.$refs.screenRef.overlay_show = false;
			},
			handleMarkerClick(item) {
				this.$utils.to(`/pages/scoreDetail/index?id=${item.id}`);
			},
			handleSearch() {
				this.$refs.pagingRef?.reload();
			},
			queryList(page, size) {


				addrList({userId:uni.getStorageSync('userId')}).then((res) => {

					// this.$refs.pagingRef?.complete(res.data?.data || []);
					this.dataList = res.data
				});
			},
			changeViewType(type) {
				this.viewType = type;
				this.$refs.pagingRef?.reload();
			},
			handleFilterChange({
				type,
				value
			}) {
				this.selectedValues[type] = value;
				this.$refs.pagingRef?.reload();
			},
			filterAll(e) {
				if (["all4", "all3", "all2", "all1"].includes(e)) {
					return "";
				}
				return e;
			},
			back(item){
				uni.$emit('choseAdd',item)
				uni.navigateBack()
			},
			edit(item){
				uni.navigateTo({
					url:'/pages/addAddress/index?data='+JSON.stringify(item)
				})
			},
			
			
		},
	};
</script>

<style lang="scss" scoped>
	.filter-container {
		display: flex;
		width: 100%;
		background-color: #fff;
		position: relative;
		z-index: 100;
	}

	.filter-tab {
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 12px 0;

		.arrow {
			font-size: 12px;
			margin-left: 4px;
			transition: transform 0.3s;
			color: #999;

			&.arrow-up {
				transform: rotate(180deg);
			}
		}
	}

	.page {
		background-color: #EFEFEF;

		.page-top {
			padding-bottom: 28rpx;

			.search-box {
				position: relative;
				z-index: 999;
			}
		}

		.filter-wrapper {
			position: relative;
			z-index: 100;
		}

		.list {
			// display: flex;
			// flex-wrap: wrap;
			// justify-content: space-between;
			padding: 0 20rpx;

			.item {
				display: flex;
				align-items: center;
				position: relative;
				// flex-direction: column;
				width: 100%;
				margin-bottom: 32rpx;
				box-sizing: border-box;
				border-radius: 16rpx;

				.detail-btn {
					position: absolute;
					right: 28rpx;
					bottom: 28rpx;
					font-size: 24rpx;
					font-weight: 500;
					color: #fff;
					background-color: $theme_color;
				}

				.texts {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					flex: 1;
					// width: 100%;
					// margin-top: 16rpx;
					// height: 216rpx;
					// margin-left: 24rpx;

					&>view {
						font-size: 28rpx;

						&>text:first-child {
							color: #677585;
						}
					}
				}
			}
		}
	}

	.tabs {
		font-weight: 400;
		font-size: 28rpx;
		margin: 30rpx;
		color: #3C3C3C;

		.on {
			font-weight: 700;
			font-size: 28rpx;
			color: #E61E1E;
		}
	}
		
	.add{
		margin: 60rpx auto;
		width: 690rpx;
		height: 90rpx;
		background: #CC0000;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		color: #fff;
		text-align: center;
		line-height: 90rpx;
	}
	.default{
		    background: #F83D3D;
		    color: #fff;
		    font-size: 24rpx;
		    padding: 2rpx 10rpx;
		    line-height: 24rpx;
		    border-radius: 6rpx;
			margin-left: 10rpx;
	}
</style>